<template>
  <div>
    <el-container>
      <el-header>
        <div class="left">电商后台管理系统</div>
        <div class="right">
          <el-button type="info" @click="over">退出</el-button>
        </div>
      </el-header>
      <el-container>
        <el-aside width="200px">
          <el-menu
            default-active="users"
            class="el-menu-vertical-demo"
            :collapse="isCollapse"
            background-color="#333744"
            text-color="#fff"
            active-text-color="#ffd04b"
            router
          >
            <el-submenu
              :index="item.path"
              v-for="(item, index) in list"
              :key="index"
            >
              <span slot="title">{{ item.authName }}</span>
              <el-menu-item
                :index="item2.path"
                v-for="(item2, index2) in item.children"
                :key="index2"
                >{{ item2.authName }}</el-menu-item
              >
            </el-submenu>
          </el-menu>
        </el-aside>
        <el-main>
          <router-view></router-view>
        </el-main>
      </el-container>
    </el-container>
  </div>
</template>

<script>
import { getMenus } from "../utils/api";

export default {
  props: {},
  data() {
    return {
      isCollapse: false,
      list: [],
    };
  },
  computed: {},
  created() {
   
  },
  mounted() {
    getMenus().then((res) => {
      this.list = res.data;
    });
  },
  watch: {},
  methods: {
   over(){
       localStorage.removeItem('token')
       this.$router.push('/login')
   }
  },
  components: {},
};
</script>

<style scoped lang="scss">
.el-header,
.el-footer {
  background-color: #333744;
  color: #fff;
  display: flex;
  justify-content: space-between;
  align-items: center;
  .left {
    font-size: 20px;
  }
}

.el-aside {
  background-color: #333744;
  color: #fff;
  text-align: center;
}

.el-main {
  background-color: #e9eef3;
  color: #333;
}
.el-menu-vertical-demo:not(.el-menu--collapse) {
  width: 200px;
  min-height: 400px;
}
.el-menu {
  width: 100%;
  height: 100vh;
}
</style>
